﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OpenMVCRM.ViewModels;
using OpenMVCRM.Entities;

namespace OpenMVCRM.Mapping
{
    public class PersonService
    {
        public static ContactPersonViewModel GetContactPersonVM(ContactPerson client)
        {
            ContactPersonViewModel personVM = new ContactPersonViewModel();
            if (client != null)
            {
                personVM.ID = client.ID;
                personVM.FirstName = client.FirstName;
                personVM.LastName = client.LastName;
                personVM.HomePhone = client.HomePhone;
                personVM.MobilePhone = client.MobilePhone;
                personVM.ParentOrganizationName = client.Organization.Name;

            }
            return personVM;

        }
        public static List<ContactPersonViewModel> GetContactPersonVMList(List<ContactPerson> personList)
        {
            List<ContactPersonViewModel> personVMList = new List<ContactPersonViewModel>();
            foreach (var personEntity in personList)
            {
               personVMList.Add(GetContactPersonVM(personEntity));
            }

            return personVMList;

        }
    }
}